package com.wiscamp.ninechapters.problems.domain.models.problems.answers;

import com.wiscamp.ninechapters.problems.enums.Actions;
import com.wiscamp.ninechapters.problems.enums.AnswerTypes;
import cube.ddd.domain.Entity;
import lombok.Data;

import java.io.Serial;

@Data
public class Answer implements Entity {

    @Serial
    private static final long serialVersionUID = 1905122041950251207L;

    /**
     * 答案编号
     */
    private long answerId;

    /**
     * 题编号
     */
    private long problemId = 0;

    /**
     * 问题编号
     */
    private long questionId = 0;

    /**
     * 答案类型枚举
     */
    private AnswerTypes answerType;

    /**
     * 答案类型编号
     */
    private int answerTypeId;

    /**
     * 答案序号
     */
    private int answerIndex = 0;

    /**
     * 分组序号
     */
    private int groupIndex = 0;

    /**
     * 解题方法
     */
    private String solutionUrl = "";


    private long answerOptionId = 0;

    /**
     * 答案超文本
     */
    private String answerHypertext = "";

    private Actions action = Actions.NONE;

    public String getAnswerText() {
        return getAnswerHypertext();
    }

    public boolean compareAnswer(String contentText) {
        // return getAnswerText().equalsIgnoreCase(contentText);
        return AnswerValidator.validateAnswerByType(answerType, contentText, getAnswerText());
    }
}
